package com.cn.scenario.util.redis;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.ClusterServersConfig;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;

/**
 * @Author Boolean
 * @Date 2022/12/30 22:27
 * @Version 1.0
 */
//@Configuration
public class RedissonConfig {

    //@Bean
    public RedissonClient redissonClient() {
        /*Config config = new Config();
        config.useClusterServers()
                .setScanInterval(2000)
                .addNodeAddress("redis://127.0.0.1:6379", "redis://redis://127.0.0.1:6380")
                .addNodeAddress("redis://redis://127.0.0.1:6381");
        RedissonClient redisson = Redisson.create(config);*/

        String nodeAddreess = "redis://127.0.0.1:6379,redis://redis://127.0.0.1:6380,redis://redis://127.0.0.1:6381";
        String[] split = nodeAddreess.split(",");
        Config config = new Config();
        ClusterServersConfig clusterServersConfig = config.useClusterServers();
        clusterServersConfig.setNodeAddresses(Arrays.asList(split));
        clusterServersConfig.setCheckSlotsCoverage(false);
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }

}

